package servlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import businessdelegate.FabricaBusinessDelegate;
import entitiesdto.MateriaPrimaDTO;


public class AsignarMPArticuloSVL extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	public AsignarMPArticuloSVL() {
		super();
	}   	


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}  	


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		HttpSession session = request.getSession(true);

		// obtener lista de  materias primas
		List<MateriaPrimaDTO> materiasPrimas = new ArrayList<MateriaPrimaDTO>();
		try {
			materiasPrimas = FabricaBusinessDelegate.getInstanace().getMateriasPrimas();
			//TODO remove
			if(materiasPrimas==null)
				System.out.println("Materias primas es null");
			// end remove
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		session.setAttribute("materiasPrimas", materiasPrimas);

		// siguiente pagina para asignar materias primas
		RequestDispatcher dispatcher = request.getRequestDispatcher("/asignarMpArticulo.jsp");
		dispatcher.forward(request, response);

	}   	  	    
}